<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2020/6/29 0029
 * Time: 10:47
 */

namespace app\common\model\mall;


use app\common\model\TimeModel;

class OrderComment extends TimeModel
{
    /**
     * 课程
     */
    public function goods(){
        return $this->belongsTo('app\common\model\mall\Account','goods_id','id')->field('id,title,thumb');
    }
    //发布评论的人
    public function user(){
        return $this->belongsTo('app\common\model\user\WxUsers','user_id','id');
    }
//子评论
    public function childs()
    {
        return $this->hasMany('app\common\model\media\Comment','pid','id');
    }
    /**
     * 课程
     */
    public function Account(){
        return $this->belongsTo('Account','goods_id','id')->field('id,title,thumb');
    }
    public static function onAfterInsert($data){

        //$self = new static();
        $article = self::withoutGlobalScope()->find($data->id);

        $article->withoutGlobalScope()->where('id',$data->id)->save(['app_id'=>self::get_appId()]);

    }

}